package com.ndp.fb.enums.publish;

import lombok.Getter;

/**
 * 结算事件
 * Created by jacky.cheng on 2015/8/12.
 */
@Getter
public enum BillingEvent {
    APP_INSTALLS("APP_INSTALLS"),
    CLICKS("CLICKS"),
    IMPRESSIONS("IMPRESSIONS"),
    LINK_CLICKS("LINK_CLICKS"),
    OFFER_CLAIMS("OFFER_CLAIMS"),
    PAGE_LIKES("PAGE_LIKES"),
    POST_ENGAGEMENT("POST_ENGAGEMENT"),
    VIDEO_VIEWS("VIDEO_VIEWS");
    private String code;

    /**
     * 解析字符串,不区分大小写，已经trim。
     *
     * @param code
     * @return
     */
    public static BillingEvent parse(String code) {
        for (BillingEvent c : BillingEvent.values()) {
            if (c.code.equalsIgnoreCase(code.trim())) {
                return c;
            }
        }
        return null;
    }

    BillingEvent(String code) {
        this.code = code;
    }
}
